package com.cxs.plan.constant;

import java.time.LocalDate;

public enum MonthEnum {
    jan(1, "一月"),
    feb(2, "二月"),
    mar(3, "三月"),
    apr(4, "四月"),
    may(5, "五月"),
    jun(6, "六月"),
    jul(7, "七月"),
    aug(8, "八月"),
    sep(9, "九月"),
    oct(10, "十月"),
    nov(11, "十一月"),
    dec(12, "十二月");

    private int code;
    private String name;

    MonthEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public  static String getNowMonthKey() {
        LocalDate currentDate = LocalDate.now();
        // 当前月份
        int code = currentDate.getMonthValue();
        for (MonthEnum monthEnum : MonthEnum.values()) {
            if (monthEnum.code == code) {
                return monthEnum.name();
            }
        }
        return null;
    }
    public static String getMonthKey(int code) {
        LocalDate currentDate = LocalDate.now();
        for (MonthEnum monthEnum : MonthEnum.values()) {
            if (monthEnum.code == code) {
                return monthEnum.name();
            }
        }
        return null;
    }
}
